<!doctype html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>编辑资料</title>
    <link rel="stylesheet" href="/static/app/lib/iconfont/iconfont.css">
    <link rel="stylesheet" href="/static/app/css/style.css">
    <script src="/static/app/lib/zy.rem.js"></script>
    <script src="/static/app/lib/jquery1.12.3.min.js"></script>
    <script src="/static/app/js/base.js"></script>
    <link rel="stylesheet" href="/static/app/css/core.css">
    <script src="/static/layer/layer.min.js"></script>

    <style>
        .add{
            width: 64%;
            height: 0.4rem;
            margin-left: 0.6rem;
            background:transparent;
            border:none;
            outline:medium;
        }
        .lad{
            margin-left: 0.6rem;
            color: #000;
            font-size: 0.25rem;
        }
        .info-links{
            margin-top: 0.5rem;
        }
        .button_lar{
            width: 90%;
            height: 0.7rem;
            margin-left: 5%;
            margin-top: 2rem;
            color: #fff;
            font-size: 0.3rem;
            border: 0;
            border-radius:0.1rem;
            background-color: #0b76ac;
            outline:none;
        }
    </style>
</head>
<body>
<div class="header">
    <div><a href="javascript:history.back(-1)"><img src="/static/app/img/fanh.png"></a></div>
    <div>密码修改</div>
    <div></div>
    <!--<div><a href="javascript:;" class="head-btn iconfont">&#xe765;</a></div>-->
</div>
<div class="center">
    {include file='public:head_img'}
    <div class="info-links">
        <form action="" method="" id="form">
            <a href="javascript:;">旧密码             <input type="password" class="add" name="pass"      value="" required="ture" placeholder="请输入旧密码"></a>
            <a href="javascript:;">新密码 &nbsp;&nbsp;<input type="password" class="add" name="newpass"  value="" required="ture" placeholder="请输入密码"></a>
            <a href="javascript:;">确认密码           <input type="password" class="add" name="newpass2" value="" required="ture" placeholder="请确认密码"></a>
        <a href="javascript:;">
        <button type="button" onclick="roleSubmit()" class="button_lar">保存</button>
        </a>
        </form>
    </div>

</div>
{include file='public:bottom'}
<script>
    //提交
    function roleSubmit(){
        if($('[name="pass"]').val() == '' ){
            layer.alert('请输入旧密码', {icon: 2});
            return false;
        }
        if($('[name="newpass"]').val() == '' ){
            layer.alert('请输入新密码', {icon: 2});
            return false;
        }
        if($('[name="newpass"]').val() == $('[name="pass"]').val() ){
            layer.alert('新密码不能和旧密码相同', {icon: 2});
            return false;
        }
        if($('[name="newpass2"]').val() != $('[name="newpass"]').val() ){
            layer.alert('确认密码不一致', {icon: 2});
            return false;
        }
        var form=document.getElementById("form");
        var formData=new FormData(form);

        $.ajax({
            url:"{:Url('setPass')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000,icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 800, icon: 1}, function(){
                    // window.location.href="{:url('index')}";
                    window.location.href='javascript:history.back(-1)';
                });
            }
        });
    }
</script>
</body>
</html>